package cn.rocksolid.sport.mq.test;

import cn.rocksolid.sport.common.Constant.MQ;
import cn.rocksolid.sport.common.mq.Mq;
import cn.rocksolid.sport.common.mq.MqHelper;
import cn.rocksolid.sport.test.RockSolidBaseTestCase;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;

public class MqTestCase extends RockSolidBaseTestCase {

  @Autowired
  @Qualifier(MQ.JMS_TEMPLATE_NAME)
  private JmsTemplate jmsTemplate;

  @Autowired
  private MqHelper mqHelper;

  @Test
  public void send() throws Exception {
//    jmsTemplate.convertAndSend(new ActiveMQTopic(MQ.VT_PAY_SUCCESS), JSON.parseObject("{a: 'b', b: 123}"));
//    Thread.sleep(Long.MAX_VALUE);
    mqHelper.pub(MQ.PAY_SUCCESS, "pay id");
    Thread.sleep(120000);
  }

//  @JmsListener(destination = MQ.PAY_SUCCESS, containerFactory = MQ.SUBSCRIBE_FACTORY)
  @Mq(destination = MQ.PAY_SUCCESS)
  public void x(String msg) {
    System.out.println(msg);
  }
}
